//
//  ApiResult.swift
//  JWBaseLib
//
//  Created by 周季伟 on 2017/12/12.
//  Copyright © 2017年 周季伟. All rights reserved.
//

public enum ApiResult<Value> {
    case success(Value)
    case failure(ApiError)
    public var isSuccess: Bool {
        switch self {
        case .success:
            return true
        case .failure:
            return false
        }
    }
    public var isFailure: Bool {
        return !isSuccess
    }
    public var value: Value? {
        switch self {
        case .success(let value):
            return value
        case .failure:
            return nil
        }
    }
    public var error: ApiError? {
        switch self {
        case .success:
            return nil
        case .failure(let error):
            return error
        }
    }
}
